<template>
  <div class="page-tools">
    <el-card>
      <div style="display: flex">
        <div style="flex: 1">
          <div v-if="$slots.before" class="before">
            <i class="el-icon-info" />
            <!-- 定义前面得插槽 -->
            <slot name="before" />
          </div>
        </div>
        <div>
          <slot name="after" />
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'PageTools',
  created() {
    // 这个 $slots 是一个对象，形如：{ 插槽名称: 插槽内容, 插槽名称2: 插槽内容2 }
    console.log(this.$slots);
  },
};
</script>

<style lang="scss">
.page-tools {
  margin: 10px 0;
  .before {
    line-height: 34px;
    i {
      margin-right: 5px;
      color: #409eff;
    }
    display: inline-block;
    padding: 0px 10px;
    border-radius: 3px;
    border: 1px solid rgba(145, 213, 255, 1);
    background: rgba(230, 247, 255, 1);
  }
}
</style>
